package com.tuanquan.flutter_plugin_tengxunvideo.pusher;

import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
import io.flutter.plugin.common.PluginRegistry;

public class FlutterTXCloudVideoViewFlutterPlugin {


    public static String NATIVE_CCTV_VIEW_TYPE_ID = "com.txvideo.flutter/TXCloudVideo";//原生控件对应的viewtypeid

    ///
    /// @Params:
    /// @Desc: 新版本注册方式
    ///
    public static void registerWith(FlutterEngine flutterEngine) {
        final String key = FlutterTXCloudVideoViewFlutterPlugin.class.getCanonicalName();
        ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
        if (shimPluginRegistry.hasPlugin(key)){
            return;
        }

        PluginRegistry.Registrar registrar = shimPluginRegistry.registrarFor(key);
        registrar.platformViewRegistry().registerViewFactory(NATIVE_CCTV_VIEW_TYPE_ID, new FlutterTXCloudVideoViewFactory(registrar.messenger(), registrar.activity()));
    }

    ///
    /// @Params:
    /// @Desc: 兼容1.12以前旧版本
    ///
    public static void registerWith(PluginRegistry registry) {
        final String key = FlutterTXCloudVideoViewFlutterPlugin.class.getCanonicalName();
        if (registry.hasPlugin(key)) return;
        PluginRegistry.Registrar registrar = registry.registrarFor(key);
        registrar.platformViewRegistry().registerViewFactory(NATIVE_CCTV_VIEW_TYPE_ID, new FlutterTXCloudVideoViewFactory(registrar.messenger(), registrar.activity()));
    }




}
